<template>
  <div>
    <!-- 搜索栏区域 -->
    <el-card class="SearchCard" body-style="padding:0px">
      <el-row>
        <el-col :span="2">
          <div class="SearchTitle">条件搜索栏</div>
        </el-col>
        <el-col :span="4">
          <el-row>
            <el-col :span="10">
              <div class="SearchLable">搜索关键字</div>
            </el-col>

            <el-col :span="14">
              <div class="SearchLable">
                <el-input placeholder="请输入内容" v-model="queryInfo.srm" clearable @clear="clearEvent"></el-input>
              </div>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="2">
          <div class="SearchLable">
            <el-button size="medium" type="primary" @click="getSearchList()">搜索</el-button>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="TableCard" :body-style="{ padding: '0px' }">
      <div>
        <el-table
          :data="tableData"
          border
          :header-cell-style="{ 'text-align':'center',background: '#3F9DFD', color: '#FFF' }"
          :cell-style="{'text-align':'center'}"
          size="medium"
          stripe
          style="width: 100%;font-size:12px"
        >
          <el-table-column type="index" width="50"></el-table-column>
          <el-table-column prop="SFXMDM" label="收费项目代码" width="100"></el-table-column>
          <el-table-column prop="SFXMMC" label="收费项目名称"></el-table-column>
          <el-table-column label="病原学送检" width="220">
            <template slot-scope="scope">
              <!-- <div v-if="scope.row.SFBYXSJ==-1">不确定</div> -->
              <el-select
                v-model="scope.row.SFBYXSJ"
                size="small"
                @change="changeCharge(scope.row.ID, $event, '')"
              >
                <el-option
                  v-for="item in LXoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="收费类别" width="220">
            <template slot-scope="scope">
              <el-select
                v-model="scope.row.SFXMLB"
                size="small"
                @change="changeCharge(scope.row.ID, '', $event)"
              >
                <el-option
                  v-for="item in LBoptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column prop="MATCHUSER" label="操作人" width="220"></el-table-column>
          <el-table-column label="操作时间" width="220">
            <template slot-scope="scope">{{getdate(scope.row.MATCHTIME)}}</template>
          </el-table-column>
        </el-table>
      </div>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryInfo.pagenum"
          :page-sizes="[20, 50, 100]"
          :page-size="queryInfo.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="this.total"
          background
        ></el-pagination>
      </div>
    </el-card>
    <!-- <el-dialog title="添加新药" :visible.sync="dialogVisible" width="55%" :before-close="handleClose">
      <div>
        <el-form
          :inline="true"
          :model="addRuleAdultData"
          class="demo-form-inline"
          label-width="150px"
          label-position="right"
        >
          <el-form-item label="药品编码">
            <el-input v-model="addRuleAdultData.drugCode"></el-input>
          </el-form-item>
          <el-form-item label="药品名称">
            <el-input v-model="addRuleAdultData.drugName"></el-input>
          </el-form-item>
          <el-form-item label="给药途径ID">
            <el-input v-model="addRuleAdultData.routeIds"></el-input>
          </el-form-item>
          <el-form-item label="给药途径类型">
            <el-input v-model="addRuleAdultData.routeType"></el-input>
          </el-form-item>
          <el-form-item label="给药途径描述">
            <el-input v-model="addRuleAdultData.routeDesc"></el-input>
          </el-form-item>
          <el-form-item label="年龄低值">
            <el-input v-model="addRuleAdultData.ageLow"></el-input>
          </el-form-item>
          <el-form-item label="是否不等于年龄低值">
            <el-select v-model="addRuleAdultData.unequalLow">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="年龄低值单位">
            <el-select v-model="addRuleAdultData.ageLowUnit">
              <el-option
                v-for="item in dateUnit"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="年龄高值">
            <el-input v-model="addRuleAdultData.ageHigh"></el-input>
          </el-form-item>
          <el-form-item label="是否不等于年龄高值">
            <el-select v-model="addRuleAdultData.unequalHigh">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="年龄高值单位">
            <el-select v-model="addRuleAdultData.ageHighUnit">
              <el-option
                v-for="item in dateUnit"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="警示内容">
            <el-input v-model="addRuleAdultData.warning"></el-input>
          </el-form-item>
          <el-form-item label="文献资料">
            <el-input v-model="addRuleAdultData.abstractDesc"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addRuleAge()">新 增</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>-->
    <!-- 显示一条规则 -->
  </div>
</template>
<script>
import { getDictCharge, getdate, UpdataCharge } from "@/api/rad";
export default {
  data() {
    return {
      queryInfo: {
        srm: "",
        page: 1,
        pageSize: 20
      },
      total: 0,
      tableData: [],
      // 收费类别(可编辑) -1不确定, 1药品,2手术,3检验,4检查,5护理,6其它
      LBoptions: [
        {
          value: -1,
          label: "不确定"
        },
        {
          value: 1,
          label: "药品"
        },
        {
          value: 2,
          label: "手术"
        },
        {
          value: 3,
          label: "检验"
        },
        {
          value: 4,
          label: "检查"
        },
        {
          value: 5,
          label: "护理"
        },
        {
          value: 6,
          label: "其它"
        }
      ],
      // 病原学送检(可编辑) -1不确定,1病原学检测,2药敏实验,3病原学检测+药敏实验,4其他
      LXoptions: [
        {
          value: -1,
          label: "不确定"
        },
        {
          value: 1,
          label: "病原学检测"
        },
        {
          value: 2,
          label: "药敏实验"
        },
        {
          value: 3,
          label: "病原学检测+药敏实验"
        },
        {
          value: 4,
          label: "其他"
        }
      ]
    };
  },
  created: function() {
    this.getDictCharge();
  },
  methods: {
    handleClose(done) {
      done();
    },
    handleSizeChange(newSize) {
      this.queryInfo.pageSize = newSize;
      this.getDictCharge();
    },

    handleCurrentChange(newPage) {
      this.queryInfo.page = newPage;
      this.getDictCharge();
    },
    async getDictCharge() {
      let res = await this.$rad.getDictCharge({
        srm: this.queryInfo.srm,
        page: this.queryInfo.page,
        pageSize: this.queryInfo.pageSize
      });
      (this.tableData = res.rows), (this.total = res.total);
      console.log(res.rows);
    },
    getdate(MATCHTIME) {
      return this.$rad.getdate(MATCHTIME);
    },
    getSearchList() {
      this.getDictCharge();
    },
    clearEvent() {},
    async changeCharge(ID, Eti, Charg) {
      console.log(ID + "  " + Eti + " " + Charg);
      let res = await this.$rad.UpdataCharge({
        id: ID,
        sfxmlb: Charg,
        sfbyxsj: Eti
      });
      console.log(res);
      if (res.code == 1) {
        this.getDictCharge();
        return this.$message({
          type: "success",
          message: res.msg
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg
        });
      }
    }
  }
};
</script>
<style>
.SearchCard {
  height: 50px;
  font-size: 12px;
}
.SearchTitle {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-right: 1px solid #c2c2c2;
}
.SearchLable {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.TableCard {
  margin-left: 3px;
  margin-top: 2px;
}
.block {
  text-align: center;
  margin-top: 12px;
  margin-bottom: 12px;
}
</style>